home *** CD-ROM | disk | FTP | other *** search
/ PC World Interactive 9 / PC World Interactive 9 - Temmuz 1998.iso / muzik / FMSYNTH.EXE / STMB.H < prev    next >
C/C++ Source or Header  |  1994-01-30  |  8KB  |  185 lines

  1. /* STMB.H -- Programming interface for FMSYNTH.DRV
  2.  *           Copyright (c) 1993 by Jamie O'Connell
  3.  *
  4.  * Currently six functions are defined: GetTimbre, SetTimbre, GetParm, 
  5.  * SetParm, GetPercMap, and SetPercMap.  With Version 2.0 of the driver
  6.  * GetPercMap and SetPercMap are somewhat obsolete, but will still be
  7.  * supported.  In addition, GetParm and SetParm operate on the Driver
  8.  * System Parameters.     
  9.  * 
  10.  * Get Timbre retrieves the Timbre parameters from the specified location.
  11.  * Timbres are Sent and Received in IBK format.
  12.  *
  13.  * SetTimbre will change the sound of an instrument in either working 
  14.  * storage or the sound of an instrument stored within a RAM Timbre Bank.
  15.  * 
  16.  * GetParm retrieves the FM Synth system parameters
  17.  * SetParm sets the System Parameters
  18.  *     
  19.  * *** OBSOLETE ***
  20.  * GetPercMap and SetPercMap perform equivalent functions on the internal
  21.  * percussion map: which note plays which percussion timbre at what pitch.
  22.  *
  23.  * NOTE - In version 1.x of the driver, only 47 percussion timbres were
  24.  *        stored -- implementing the General MIDI percussion map.  For
  25.  *        version 2.0, we store an entire 128 timbre bank for percussion.
  26.  *        In addition, the Pitch parameter which used to be in the Percussion
  27.  *        map is now stored directly in the Timbre, and the position within
  28.  *        the bank defines the MIDI Key mapping. For instance, the Timbre
  29.  *        stored in slot 35 of the percussion bank is the first GM Bass Drum.
  30.  *
  31.  *        Passing the obsolete TMB_BANK_PERCUSSION to GetTimbre will continue 
  32.  *        to retrieve one of the 47 GM percussion timbres.  For example,
  33.  *        requesting Timbre 0 will retrieve percussion Timbre 35.  To access
  34.  *        the entire Percussion bank use the new TMB_PERCUSSION constant.     
  35.  *     
  36.  * **************************************************************************
  37.  *
  38.  * Working storage is the current version of a Timbre stored on a 
  39.  * per-channel basis.  It is the version of the timbre which is used to
  40.  * sound a voice for the channel when a note is to be played. The working 
  41.  * storage is overwritten by Bank storage whenever a program change is 
  42.  * received for the channel.
  43.  *
  44.  * The RAM Timbre bank is either the internal Timbre Bank, or one which 
  45.  * has been loaded from a file.  In either case it is volatile storage
  46.  * which is overwritten when the bank is reloaded.
  47.  */
  48.  
  49. #ifndef  __STMB_H
  50. #define  __STMB_H
  51.  
  52. #define TMB_WORKING_STORAGE      0
  53. #define TMB_BANK_STORAGE         1
  54. #define TMB_BANK_PERCUSSION      2 /* OBSOLETE */
  55. #define TMB_PERCUSSION           3 /* Use this to retrieve percussion now */
  56.  
  57. #define FIRSTDRUMNOTE  35
  58. #define LASTDRUMNOTE   81
  59. #define NUMDRUMNOTES   (LASTDRUMNOTE - FIRSTDRUMNOTE + 1)
  60.  
  61. /* The timbre definition (IBK - SBI Format) */
  62.  
  63. typedef struct _tagTIMBRE {
  64.         BYTE MSndChr;
  65.         BYTE CSndChr;
  66.         BYTE MKSLOut;
  67.         BYTE CKSLOut;
  68.         BYTE MAtkDcy;
  69.         BYTE CAtkDcy;
  70.         BYTE MSusRel;
  71.         BYTE CSusRel;
  72.         BYTE MWavSel;
  73.         BYTE CWavSel;
  74.         BYTE FDBkCon;
  75.         BYTE PercVoc;   /* New for version 1.x -- Bass Drum=6, Snare=7 */
  76.                         /* Tom-Tom=8,  Cymbal=9, HiHat=10 */
  77.         CHAR Transpos;  /* New for version 1.x -- # of semitones offset */ 
  78.         BYTE PrcPitch;  /* New for version 2.0 */
  79.         BYTE Future[2];
  80.         } TIMBRE;
  81.         
  82. typedef TIMBRE FAR * LPTIMBRE;
  83.  
  84. /* *** OBSOLETE ******************************************************* */
  85.  
  86. typedef struct _tagPERCMAP {
  87.         BYTE patch;                 // the patch to use 
  88.         BYTE note;                  // the note to play  
  89.         } PERCMAP;
  90.  
  91. typedef PERCMAP FAR * LPPERCMAP;
  92.  
  93. /* The percussion map provides info for each pecussion MIDI key   
  94. ** To access (retrieve or send) the Percussion map you create an
  95. ** array of these things: PERCMAP percMap[NUMDRUMNOTES]; 
  96. ** and pass it to GetPercMap or SetPercMap.  The buffer must be at least
  97. ** sizeof(PERCMAP) * NUMDRUMNOTES = 94 bytes large.
  98. */
  99.  
  100. extern void FAR  PASCAL GetPercMap(LPPERCMAP lpPM);
  101. extern void FAR  PASCAL SetPercMap(LPPERCMAP lpPM);
  102.  
  103. /* ********************************************************************* */
  104.  
  105.  
  106. extern WORD FAR  PASCAL GetTimbre(WORD wLoc, LPTIMBRE lpTmb, WORD wSrc);
  107. extern WORD FAR  PASCAL SetTimbre(WORD wLoc, LPTIMBRE lpTmb, WORD wDest);
  108.  
  109. /*   
  110.  *  DESCRIPTION
  111.  *
  112.  *  wLoc - If the Destination (wDest) or Source (wSrc) is TMB_WORKING_STORAGE,
  113.  *         then wLoc is the channel number (0 based) for storing the Timbre.  
  114.  *         If the Destination is TMB_BANK_STORAGE, then the most
  115.  *         significant byte of wLoc (HIBYTE(wLoc)) is the Bank number
  116.  *         (valid values: 0 - 4), and the least significant byte is the
  117.  *         timbre number (0-127).
  118.  *         If the destination is TMB_PERC_BANK, the Bank number is ignored
  119.  *         (there is only one percussion bank), and the LSB is the timbre
  120.  *         number (0-46).      
  121.  *
  122.  *  lpTmb  A far pointer to a TIMBRE structure, defining the new timbre to
  123.  *         store.  The structure should be the full 16 bytes in length.
  124.  *                                                                    
  125.  *  wSrc   This value determines how wLoc is interpreted when retrieving
  126.  *         the timbre.  If wSrc is TMB_WORKING_STORAGE the timbre is retrieved
  127.  *         from working storage (wLoc is a channel number). If wSrc is 
  128.  *         TMB_BANK_STORAGE or TMB_PERCUSSION, the timbre is 
  129.  *         retrieved from the specified bank and timbre slot (wLoc is the 
  130.  *         combination of Bank & Timbre#).
  131.  *
  132.  *  wDest  This value determines how wLoc is interpreted and the final 
  133.  *         destination for the timbre.  If wDest is TMB_WORKING_STORAGE the
  134.  *         channel timbre info is updated, and future voices on channel will
  135.  *         sound this timbre. If wDest is TMB_BANK_STORAGE ot TMB_PERCUSSION, 
  136.  *         both the Bank Timbre, and any channels set to this Bank and Timbre 
  137.  *         are updated. Any future notes playing this bank and timbre will 
  138.  *         sound the timbre.
  139.  *                                                             
  140.  *  Return Value
  141.  *         If all goes well, 0 is returned, otherwise a non-zero value is
  142.  *         returned indicating, an incorrect or out-of-range parameter.  
  143.  *         The values within the TIMBRE structure itself are not checked
  144.  *         for validity, but stored as supplied.
  145.  */
  146.  
  147. typedef struct _tagSYSPARM {
  148.         BYTE    fStereo;      /* 1 = on, 0 = off */
  149.         BYTE    fPercussion;  /* 1 = on, 0 = off */
  150.         BYTE    PerChannel;   /* if Percussion mode = 1: channel = 0-15 */
  151.                               /* (i.e. MIDI channel 10 is value 9)      */
  152.         BYTE    DftBank;      /* 0-4 (Bank1 - Bank5) */
  153.         BYTE    fVibDepth;    /* 0 = light, 1 = deep */
  154.         BYTE    fTremDepth;   /* 0 = light, 1 = deep */
  155.         BYTE    BendRange;     /* 0-12 semitones (1 octave) */
  156.         BYTE    fSaveSettings;/* 1 = Save the settings in the INI file */
  157.         BYTE    ChanMap[16];  /* 1 = on, 0 = off -- one byte per channel */
  158.         char    PercBoost;     /* signed: -64 to +63 -- 0 is no boost */
  159.         } SYSPARM, FAR *LPSYSPARM;
  160.     
  161. /* You can use sizeof(SYSPARM) as the StructLen parameter */
  162.             
  163.         
  164. extern WORD FAR  PASCAL GetParm(LPSYSPARM lpSysParm, WORD StructLen);
  165. extern WORD FAR  PASCAL SetParm(LPSYSPARM lpSysParm, WORD StructLen);
  166.  
  167. /*   
  168.  *  DESCRIPTION
  169.  *
  170.  *  lpSysParm   - a FAR pointer to a SYSPARM struct as shown above.  All
  171.  *                parameters are retrieved and set at once.  When setting
  172.  *                parameters the driver is reinitialized so the driver
  173.  *                is reset when the function returns.
  174.  *
  175.  *  StructLen     Is the size of SYSPARM.  Passing this value allows future
  176.  *                additions and modifications to the structure.
  177.  *
  178.  *  Return Value
  179.  *         If all goes well, 0 is returned, otherwise a non-zero value is
  180.  *         returned indicating, an incorrect or out-of-range parameter.  
  181.  *     
  182.  */
  183.  
  184. #endif
  185.